
<div align="left">
        <?php if(!empty($this->errMsg)) :?>
                <?php $this->listError($this->errMsg,$this->lang_data); ?>
        <?php endif; ?>
</div>
<form name="formIndex" method="post" action="<?php echo $this->baseUrl; ?>/backend/servicetype/index">

<input type="hidden" name='dellist' value="" />
<input type="hidden" name="command" value=""/>
<input type="hidden" name="hidUserId" value="<?php echo $this->user->id; ?>">


	<table class="controlbar" cellpadding="5">
		<tr>
			<td align="left" width="50%">
                            <img class="btnAdd" src="<?php echo $this->baseUrl ?>/public/media/images/default/add.png" style="cursor: pointer"  onclick="window.location='<?php echo  $this->baseUrl . '/backend/servicetype/add';  ?>'" />
 				<img src="<?php echo $this->baseUrl ?>/public/media/images/default/delete.png" style="cursor: pointer" onclick='javascript:delMultiItem()'/>
			</td>
			<td width="50%" align="right">
				<?php echo $this->paginationControl($this->paginator, 'Elastic', 'pagination.phtml'); ?>
			</td>
		</tr>
	</table>
	<table width='100%' border='0' class='datatable' id="dataTable">
			<tr>
				<th width='1%' scope='col' ><input  name='chkall' type='checkbox' onclick='checkAll(document.formIndex)' value='0' /></th>
				<th align='center' width='15%' scope='col'><?php print $this->lang_data->_('Vietnamese Name'); ?></th>
				<th align='center'  scope='col' width="25%"><?php print $this->lang_data->_('English Name'); ?></th>
				<th align='center'  scope='col'><?php print $this->lang_data->_('Action'); ?></th>
			</tr>
			<?php
                            //render data pagination
                            $this->listServicetypes($this,$this->baseUrl,$this->paginator);
			?>

	</table>

</form>
<script type="text/javascript">
function delList(id)
{
    if(confirm("Do you want to delete this service type ?") == true)
    {
        var strId = "id=" + id;

        var resText = $.ajax({
               type: "POST",
               url: "<?php echo $this->baseUrl.'/'.$this->moduleName.'/'.$this->controllerName.'/delete' ?>",
               data: strId,
               async: false,
               success: function(msg){

               }
             }).responseText;

        if(resText == '')
        {
            alert( "Xóa thành công");
            var idNode = 'row' + id;
            $('.'+idNode+'').remove();
        }
        else
        {
            alert(resText);
        }
    }
}

function delMultiItem()
{
        var i=0;
        var chk = $('form').find("input[name='chkid']");
        for (i; i< chk.length;i ++)
            if (chk[i].checked == true) break;

        if (i == chk.length)
        {
            alert('Please chose service type !');
            return false;
        }
        if(confirm('Do you want to delete this service type(s) ?') == true){

            var strId = "id=";

            var i=0;
            for (i; i< chk.length;i ++)
                if (chk[i].checked == true)
                    strId = strId + chk[i].value + ',';

            var resText =  $.ajax({
                       type: "POST",
                       url: "<?php echo $this->baseUrl.'/'.$this->moduleName.'/'.$this->controllerName.'/delete' ?>",
                       data: strId,
                       async: false,
                       success: function(msg){}
                     }).responseText;

            if(resText == '')
            {
                alert( "Xóa thành công");
                top.location = '<?php echo $this->baseUrl.'/'.$this->moduleName.'/'.$this->controllerName ?>';
            }
            else
            {
                alert(resText);
                top.location = '<?php echo $this->baseUrl.'/'.$this->moduleName.'/'.$this->controllerName ?>';
            }
        }
}

</script>